package com.will.txj.aj.security.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author: wen-yi;
 * @date: 2021/12/5 10:55;
 * @Description: 配置拦截器
 */
@Configuration
public class MvcInterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private CharacterInterceptor characterInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册Interceptor拦截器
        InterceptorRegistration interceptor = registry.addInterceptor(characterInterceptor);
        //所有路径都被拦截
        interceptor.addPathPatterns("/**");
        //interceptor.addPathPatterns("/page/**");
        //添加不拦截路径
        /*
        interceptor.excludePathPatterns(
                "/",
                "/api/code/**",
                "/api/admin/login"
        );
         */
    }
}
